<template>
  <el-container>
    <el-aside width>
      <el-menu default-active="1-4-1"
               class="el-menu-vertical-demo"
               @open="handleOpen"
               @close="handleClose"
               :collapse="isCollapse"
               :router="true">
        <subMenu :sideMenu="$store.state.sideMenu"></subMenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <el-row type="flex"
                class="row-bg"
                justify="space-between">
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'"
                 @click="isCollapse=!isCollapse"></i>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple-light">
              航航航管理系统
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <el-button type="primary"
                         @click="quit">退出登录</el-button>
            </div>
          </el-col>
        </el-row>
      </el-header>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import subMenu from "../../components/subMenu.vue";
export default {
  data () {
    return {
      isCollapse: false,
    };
  },
  components: {
    subMenu,
  },
  methods: {
    handleOpen (key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath);
    },
    quit () {
      //跳转到登陆页面
      this.$router.push('/login');
      //清除本地储存的token
      localStorage.removeItem('hanghanghang-token');
      //刷新页面，因为addroutes之后，无法清空，会导致不同权限路由混乱
      location.reload();
    }
  },
};
</script>

<style lang="scss" scoped>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
  padding: 0;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
  padding: 0;
}

.el-container {
  margin-bottom: 40px;
  height: 100%;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-row {
  margin-bottom: 20px;
  /* &:last-child {
    margin-bottom: 0;
  } */
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  background-color: #f9fafc;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>